package com.scientific.research.gobang.controller;

import com.scientific.research.gobang.service.CodeGameService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RequestMapping("CodeGame")
@RestController//Rest是让所有方法的返回值都是JSON格式
public class CodeGameController {
    @Resource(name = "codeGameServiceImpl")
    CodeGameService codeGameService;

    //返回目前所有用户的Rank排名、胜率、匹配场数，显示在CodeAndCode.html页面
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("LodeUserTable")
    public List LodeUserTable() {
        return codeGameService.LodeUserTable();
    }

    //整个项目的内核，负责编译连接运行两个用户的代码，保存结果，并用Redis全局变量监听当前整个项目排队编译的代码数量
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("SaveRunCode")
    public void SaveRunCode(@RequestBody Map map) {
        codeGameService.SaveRunCode(map);
    }
}
